package com.easy.hutool;

import cn.hutool.core.date.*;
import cn.hutool.core.date.format.FastDateFormat;
import cn.hutool.core.lang.Console;

import java.sql.Date;
import java.util.Calendar;

/**
 * @author wxk
 * @Description: TODO 时间转换测式
 * @date 2021/7/6
 */
public class DateTest {


    public static void main(String[] args) {
        int lastDay = Month.of(Calendar.JANUARY).getLastDay(false);
        System.out.println("lastDay:" + lastDay);
        String start = "2021-06-20 11:07:51";
        String end = "2021-06-29 22:52:37";
        String nowTime = "";

        /*日期时间差*/
        DateTime date1 = DateUtil.parse(start);
        DateTime date2 = DateUtil.parse(end);
        long betweenDay = DateUtil.between(date1, date2, DateUnit.DAY);
        long betweenHour = DateUtil.between(date1, date2, DateUnit.HOUR);
        System.out.println("日期时间差:" + betweenDay + "天");
        System.out.println("日期时间差:" + betweenHour + "小时");

        /*星座和属相*/
        String chineseZodiac = DateUtil.getChineseZodiac(1995);
        String zodiac = DateUtil.getZodiac(Month.FEBRUARY.getValue(), 19);
        System.out.println("星座:" + zodiac);
        System.out.println("属性:" + chineseZodiac);

        //通过公历构建
        ChineseDate date = new ChineseDate(DateUtil.parseDate("1995-01-31"));
        // 一月
        date.getChineseMonth();
        // 正月
        date.getChineseMonthName();
        // 初一
        date.getChineseDay();
        // 庚子
        date.getCyclical();
        // 生肖：鼠
        date.getChineseZodiac();
        // 传统节日（部分支持，逗号分隔）：春节
        date.getFestivals();
        // 庚子鼠年 正月初一
        date.toString();
        System.out.println("公历："+date);

        //通过公历构建
        ChineseDate chineseDate = new ChineseDate(DateUtil.parseDate("1995-01-31"));
        // 庚子年甲申月癸卯日
        String cyclicalYMD = chineseDate.getCyclicalYMD();
        System.out.println("天干地支:" + cyclicalYMD);
    }
}
